package cn.kgc.springcloud.controller;

import cn.kgc.springcloud.entity.Group;
import cn.kgc.springcloud.service.GroupService;
import cn.kgc.springcloud.vo.GroupVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * @Author: 课工场
 * @Version: v1.0  2023/2/27
 * @Description:
 */
@RestController
@RequestMapping("groups")
public class GroupController {

    @Autowired
    private GroupService groupService;

    @GetMapping
    public List<GroupVO> getList() {
        return groupService.getList();
    }


    @PostMapping
    public Group addGroup(@RequestBody Group group) {
        group.setCreatedate(new Date());
        groupService.save(group);
        return group;
    }


}
